fork download
  1. #!/usr/bin/env bash
  2.  
  3. read w h d s
  4. r=$(bc<<<"scale=5;($d^4 / $h^4 - 1) * $h * $w * 3 / 13 / (1 + $s)")
  5. r=${r#-}
  6. q=$(bc<<<"scale=5;sqrt($r)")
  7. t="$(for i in $(seq 1 ${q%%.*}); do
  8. m=$(bc<<<"scale=5;$r/$i")
  9. echo "${m##*.}|$i: $m"
  10. done | sort -n | cut -d\| -f2-)"
  11. echo -e "\nsqrt = $q\n"
  12. head -15 <<<"$t"
  13. echo ""
  14. tail -15 <<<"$t"
  15.  
Success #stdin #stdout 0.24s 5292KB
stdin
70 169 410 3
stdout
sqrt = 151.52517

151: 152.05218
150: 153.06586
26: 883.07231
135: 170.07318
149: 154.09315
102: 225.09686
9: 2551.09779
76: 302.10368
90: 255.10977
85: 270.11623
46: 499.12782
75: 306.13173
148: 155.13432
13: 1766.14462
59: 389.15051

8: 2869.98501
10: 2295.98801
14: 1639.99143
16: 1434.99250
20: 1147.99400
28: 819.99571
35: 655.99657
40: 573.99700
41: 559.99707
56: 409.99785
70: 327.99828
80: 286.99850
82: 279.99853
112: 204.99892
140: 163.99914